﻿using BunnyEater.Domain.SystemManagement;
using BunnyEater.Domain.Traceable;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BunnyEater.EntityFrameworkCore
{
    public class BunnyEaterContext: DbContext
    {
        public BunnyEaterContext(DbContextOptions<BunnyEaterContext> options) : base(options)
        {
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //创建用户表非聚集索引（[Account]【账号】字段），以便登录查询
            modelBuilder.Entity<User>().HasIndex(e => e.Account).IsUnique();
        }

        #region 系统

        /// <summary>
        /// 用户信息表
        /// </summary>
        public DbSet<User> User { get; set; }
        public DbSet<Role> Role { get; set; }
        public DbSet<Permissions> Permissions { get; set; }
        public DbSet<UserRole> UserRole { get; set; }
        public DbSet<RolePermissions> RolePermissions { get; set; }
        public DbSet<Material> Material { get; set; }
        public DbSet<Cultured> Cultured { get; set; }
        public DbSet<Firm> Firm { get; set; }
        public DbSet<Health> Health { get; set; }
        public DbSet<Process> Process { get; set; }
        public DbSet<Butchery> Butchery { get; set; }

        #endregion

    }
}
